package cn.jsu.oj.dispatchServer.satellite.mode.strategy;

import cn.jsu.oj.dispatchServer.satellite.netty.starter.SatelliteStarter;
import cn.jsu.oj.dispatchServer.satellite.pojo.net.LossNet;
import org.springframework.stereotype.Service;

/**
 * 客户端策略
 *
 * @author shan
 * @date 2022/07/13
 */
@Service("clientStrategy")
public class ClientStrategy extends AbsStrategy {

    @Override
    public void execute() {
        LossNet lossNet = (LossNet) super.premise;
        if (!SatelliteStarter.activeSign) {
            return;
        }
        try {
            super.satelliteServer.getChannel().writeAndFlush(lossNet.serialize());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
